package com.geely.jdemo.typelimit;

import org.junit.Test;

import java.util.ArrayList;

/**
 * 3.限定类型变量
 */
public class ArrayAlg {
    //<T extends >继承类必须放首位，单继承多实现，以&连接接口
    public static <T extends ArrayList & Comparable> T min(T a, T b) {
        if (a.compareTo(b) > 0) return a;
        else return b;
    }

    static class TestMin extends ArrayList implements Comparable {
        @Override
        public int compareTo(Object o) {
            return 0;
        }
    }

    @Test
    public void mainTest() {
        min(new TestMin(), new TestMin());
    }
}
